<!doctype html>
<html lang="en">
	<head>
		<title>Using custom icon</title>
		<meta
			property="og:description"
			content="This plugin provides default icons for each TerraDraw mode button. You can change default icon if you would like to use your own."
		/>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<link rel="stylesheet" href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" />
		<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
		<style>
			body {
				margin: 0;
				padding: 0;
			}
			html,
			body,
			#map {
				height: 100%;
			}

			/** Find class name from maplibre-gl-terradraw.css to overwrite */
			.maplibregl-terradraw-add-polygon-button {
				/** 
				change to draw-polygon from fontawesome (https://fontawesome.com/v6/icons/draw-polygon?f=classic&s=solid)
				1. copy SVG from somewhere or create your own
				2. convert SVG to base64 data uri at https://www.svgviewer.dev/svg-to-data-uri
				3. replace background with new data uri.
				*/
				background: url('') !important;
				background-position: center !important;
				background-repeat: no-repeat !important;
				/**
				You may need to adjust icon size to fit plugin control button.
				*/
				background-size: 80% !important;
			}
		</style>
	</head>
	<body>
		<script src="https://cdn.jsdelivr.net/npm/@watergis/maplibre-gl-terradraw@latest/dist/maplibre-gl-terradraw.umd.js"></script>
		<link
			rel="stylesheet"
			href="https://cdn.jsdelivr.net/npm/@watergis/maplibre-gl-terradraw@latest/dist/maplibre-gl-terradraw.css"
		/>
		<div id="map"></div>

		<script>
			const map = new maplibregl.Map({
				container: 'map',
				style: 'https://demotiles.maplibre.org/style.json',
				center: [0, 0],
				zoom: 1,
				maxPitch: 85
			});

			const drawControl = new MaplibreTerradrawControl.MaplibreTerradrawControl({
				modes: ['polygon', 'delete'],
				open: true
			});
			map.addControl(drawControl, 'top-left');
		</script>
	</body>
</html>
